/******************************************************************
 * Copyright (c) 2007 - 2007, Simon Guerard, All rights reserved.
 * 
 * Projet de jeu de course au large.
 * 
 * This File is part of Sail-Race
 * 
 * Sail-Race is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
 * 
 * Sail-Race is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with Sail-Race; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 */
package net.simcafamily.sailrace.listener;

import java.awt.Component;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import net.simcafamily.sailrace.panel.SimpleInternalFrame;


/**
 * @author c4668
 * 
 */
public class ToolBarMouseListener implements MouseListener {

  SimpleInternalFrame component;

  /**
   * @param composant
   */
  public ToolBarMouseListener(final SimpleInternalFrame composant) {
    super();
    component = composant;
  }

  /**
   * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
   */
  public void mouseClicked(final MouseEvent e) {
    if (component.getContent() != null) {
      if (component != null && component.getParent() != null && component.getParent().getComponents() != null) {
        for (final Component compo : component.getParent().getComponents()) {
          if (compo instanceof SimpleInternalFrame && ((SimpleInternalFrame) compo).getContent() != null) {
            ((SimpleInternalFrame) compo).getContent().setVisible(false);
          }
        }
      }
      component.getContent().setVisible(true);
      component.updateUI();
    }
  }

  /**
   * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
   */
  public void mousePressed(final MouseEvent e) {
  }

  /**
   * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
   */
  public void mouseReleased(final MouseEvent e) {

  }

  /**
   * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
   */
  public void mouseEntered(final MouseEvent e) {

  }

  /**
   * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
   */
  public void mouseExited(final MouseEvent e) {

  }

}
